using System;
using System.IO;
using System.Xml.Serialization;

namespace WPChanger
{
	/// <summary>
	/// Summary description for SettingsManager.
	/// </summary>
	public class SettingsManager
	{
		public SettingsManager(){}

		public static void saveSettings(string fileName, Settings mySettings)
		{
			XmlSerializer s = new XmlSerializer( typeof( Settings ) );
			TextWriter w = new StreamWriter( fileName );
			s.Serialize( w, mySettings );
			w.Close();
		}

		public static Settings loadSettings(string fileName)
		{
			// Deserialization
			if (File.Exists(fileName))
			{
				XmlSerializer s = new XmlSerializer( typeof( Settings ) );
				Settings mySettings;
				TextReader r = new StreamReader(fileName);
				mySettings = (Settings)s.Deserialize( r );
				r.Close();
				return mySettings;
			}
			else
			{
				return new Settings();
			}
		}
	}
}
